<?php
$output = "";
if($_SESSION['user_role'] == 1||$_SESSION['user_role'] == 2||$_SESSION['user_role'] == 3){
	if(!empty($_GET['movie'])&&!isset($_POST['add_offer'])){
		$movie_title = getMovieInformation($_GET['movie'],"title");
		// Title
		$output .= "<h1>Add an offer to $movie_title</h1><br>";
		$output .= "<form action='#' method='post'>";
		$output .= "<table width=80%>";
		$output .= "<tr>";
		$output .= "<th>The price for which I'll sell this movie</th>";
		$output .= "<th></th>";
		$output .= "</tr>";
		$output .= "<tr>";
		$output .= '<td><input type="number" size="6" maxlength="6" name="price" value="15.00">CHF</td>';
		$output .= "<td><input type=submit name='add_offer' value='Add Offer to Movie' /></td>";
		$output .= "</tr>";
		$output .= "</table></form>";
	}
	
	if(isset($_POST['add_offer'])&&!empty($_POST['price'])){
		if(addOffer($_GET['movie'], $_POST['price']))
		$output .= "<font color=green>Offer has been added</font><br><br>";
		else
		$output .= "<font color=red>Offer has not been added, sql errors</font><br><br>";
	}
	
}else{
	$output.= "must be logged in";
}
echo $output;
?>